<template>
  <el-dialog :title="dialogProps.title" :visible.sync="dialogProps.visible" width='700px'  align='right'  append-to-body  :fullscreen = 'Global.currentDevice'>
        <el-button  type="primary" size="mini" round  @click="add()"  class='mb10'  >新增</el-button>
        <el-table
            :data="tableData"  border 
            >
             
                <el-table-column  prop="dataTimeYear" label="募集日期"    align='center'>
                     <template  v-slot='list'>
                          <span >{{list.row.dataTimeYear}}年{{list.row.dataTimeMonth}}月/第{{list.row.dataTimeWeek}}周</span>
                    </template> 
                </el-table-column>
                <el-table-column  prop="weekRaiseAmt" label="本周募集金额(万元)"    align='center'>
                    <template  v-slot='list'>
                          <span >{{list.row.weekRaiseAmt | pro_exa_produce}}</span>
                    </template>
                </el-table-column>
                <el-table-column  prop="monthRaiseAmt" label="本月募集金额(万元)"    align='center'>
                    <template  v-slot='list'>
                          <span >{{list.row.monthRaiseAmt | pro_exa_produce}}</span>
                    </template>
                </el-table-column>
                <el-table-column  prop="totalRaiseAmt" label="累计募集金额(万元)"    align='center'>
                    <template  v-slot='list'>
                          <span >{{list.row.totalRaiseAmt | pro_exa_produce}}</span>
                    </template>
                </el-table-column>
                <el-table-column  prop="listingCharged" label="已收取挂牌费用(万元)"    align='center'>
                    <template  v-slot='list'>
                          <span >{{list.row.listingCharged | pro_exa_produce}}</span>
                    </template>
                </el-table-column>
                <el-table-column  prop="date" label="创建日期"     align='center'  width='100'>
                    <template  v-slot='list'>
                          <span >{{list.row.createTime | formatDates}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作"                               align="center"  >
                    <template v-slot="list">
                            <el-button    type="primary" size="mini" round @click="handleEdit(list.row)">编辑</el-button>
                    </template>
          </el-table-column>
      </el-table>

      <!-- 分页 -->
            <el-pagination class='mt28'   align='center'  v-if='Total>5'
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="1"
                    :page-size="5"
                    :pager-count="5"
                    layout="total, prev, pager, next, jumper"
                    :total="Total">
            </el-pagination>
      
      
      <div slot="footer" class="dialog-footer">
            
            <el-button type="primary" @click="dialogProps.visible = false">确 定</el-button>
      </div>
      <!-- //add -->
      <AddNewCollect ref='add_collection'  v-on:save-finished='pageInit()'></AddNewCollect>
  </el-dialog>
</template>

<script >

  import  { addCollect,listCollect }  from '@/api/professional_work/product/index'
  //募集信息
import  AddNewCollect  from  '@/components/professional_work/product/AddNewCollect'
export default {
  name: 'product_Collection',
  data() {

    return {

      //dialogo基本信息  显示隐藏状态  title 
      dialogProps: {
        visible: false,
        action: '',
        title: '添加募集信息'
      },
      search:{
          pageNo:1,
          pageSize:5,
      },
      tableData:[],
      Total:null,
      form:{
          prdCode:'',//当前产品code
          prjCode:'',//当前code
      },

    }
  },
  created(){
    
    
  },
  methods: {
    /*表格数据初始化*/
    pageInit(){
        // console.log(this.form.prdCode)
        listCollect(this.search,this.form.prdCode).then(res=>{
            if(res.data.flag == true){
                this.tableData = res.data.dataList
                this.Total = res.data.totalRs
            }
        }).catch(error=>{
          console.log(error)
        })
    },
    
     //填写募集信息
    add(){
        this.$refs.add_collection.$emit('openDialog',this.form.prdCode,this.form.prjCode)
    },
    handleEdit(row){
        this.$refs.add_collection.$emit('openEditDialog',row)
    },
    handleSizeChange(val) {
      this.search.pageSize = val;
      this.pageInit()
    },
    /*页数变化 事件触发
     *@method 方法名
     *@for 所属类名
     *@param{val} 第几页
     *@return {} 
    */
    handleCurrentChange(val) {
      this.search.pageNo = val
      this.pageInit()
    },
  },
  mounted: function() {
    this.$nextTick(() => {
      this.$on('openDialog', function(code,prjCode) {
        this.dialogProps.visible = true
        this.form.prdCode = code
        this.form.prjCode = prjCode
        this.pageInit()
      })
      
    })
  },

   
  updated(){
    
  },
  components:{
    AddNewCollect
  }
}
</script>

<style  scoped>
</style>


